Skip to content

Conversation

@YatindraRai002
Copy link

@YatindraRai002 YatindraRai002 commented Dec 16, 2025

…ion events

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Closes: #issue_number
  • Related: #issue_number

2. Or, if no issue exists, describe the change:

If applicable, please follow the issue templates to provide as much detail as
possible.

Problem:
A clear and concise description of what the problem is.

Solution:
A clear and concise description of what you want to happen and why you choose
this solution.

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Please include a summary of passed pytest results.

Manual End-to-End (E2E) Tests:

Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Add any other context or screenshots about the feature request here.

@google-cla
Copy link

google-cla bot commented Dec 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @YatindraRai002, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug that caused the code executor to fall into an infinite loop. The core problem stemmed from an incorrect classification of code execution events as 'empty' content, leading to their unintended exclusion from the LLM context. The solution involves refining the content filtering logic to explicitly preserve executable code and its results. This ensures that the agent's interaction history remains complete and prevents the loop. Comprehensive new tests have been added to verify the robustness of this fix and prevent regressions.

Highlights

  • Infinite Loop Fix: Resolved an issue where the code executor could enter an infinite loop by incorrectly filtering out code execution events as empty content.
  • Content Definition Update: Modified the _contains_empty_content function to properly recognize events containing executable_code or code_execution_result as valid, non-empty content.
  • New Test Cases: Introduced a new integration test (test_code_executor_fix.py) and a unit test (test_code_execution_events_are_not_skipped) to validate the fix and ensure code execution events are correctly handled and not skipped.
  • Sample Agent Update: Updated the hello_world sample agent to use the gemini-pro model and added a max_output_tokens limit to its content generation configuration.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot
Copy link
Collaborator

adk-bot commented Dec 16, 2025

Hello @YatindraRai002, thank you for your contribution!

Before we can review this PR, please address the following points from our contribution guidelines:

  • Sign our Contributor License Agreement (CLA): It looks like the CLA check has failed. Please visit https://cla.developers.google.com/ to sign the agreement.
  • Link to an Issue: Could you please link to the GitHub issue that this PR is addressing? If one doesn't exist, please create one.
  • Fill out the Testing Plan: Please fill out the "Testing Plan" section in your PR description. While I can see you've added new tests, this section is important for reviewers to understand how you verified your changes.

This information will help us to review your PR more efficiently. Thanks!

Response from ADK Triaging Agent

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Dec 16, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a potential infinite loop within the code executor by ensuring that code execution and result events are not incorrectly filtered out as empty. The core logic change in src/google/adk/flows/llm_flows/contents.py is sound and is well-supported by a new unit test. However, the newly added test script, test_code_executor_fix.py, contains a hardcoded absolute path, which is a critical issue that makes the test non-portable and needs to be resolved. Additionally, this new test script is placed at the root of the repository, which is unconventional; it would be better located within the tests directory to maintain project structure.

Comment on lines 68 to 69
sys.path.insert(0, 'c:\\Users\\Asus\\Downloads\\adk-python\\src')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This code includes a hardcoded absolute path specific to a local machine. This will cause the script to fail for other developers and in any CI/CD environment. Please remove this path manipulation. The script should be run from an environment where the src directory is already included in the PYTHONPATH.

For example, you can run this script from the project's root directory with:

PYTHONPATH=src python test_code_executor_fix.py

@@ -0,0 +1,75 @@
"""Test to verify the code executor infinite loop fix."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test script is located at the root of the repository, which is not standard for this project. For better organization and to align with existing test structure, please consider moving it to an appropriate subdirectory within the tests folder, such as tests/integration/.

@ryanaiagent ryanaiagent self-assigned this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants